﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.Windows.Media.Animation;
using System.IO;


namespace _1vs100
{
    /// <summary>
    /// Interaction logic for TestWindow.xaml
    /// </summary>
    public partial class TestWindow : Window
    {
        public TestWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //CreateDynamicProgressBarControl();
            //readTextFile();
            //seeOtherWindows();
           
        }

        private void test()
        {
            Options p = new Options();
            p.ShowDialog();
        }

        private void seeOtherWindows()
        {            
            //txtOutput.Text = ((App)Application.Current).Rule.CurrentPlayer.Name + ((App)Application.Current).Rule.Difficulty + ((App)Application.Current).Rule.Timer.ToString();
            //((App)Application.Current).cur
        }

        private void readTextFile()
        {
            try
            {
                using (StreamReader reader = new StreamReader("~/QuestionsFile.txt"))
                {
                    String line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        txtOutput.Text += line;
                        txtOutput.Text += "\n";
                    }
                }

            }
            catch (Exception e)
            {
                MessageBox.Show("error reading");
            }

        }

        private void CreateDynamicProgressBarControl()
        {

            ProgressBar PBar2 = new ProgressBar();

            PBar2.IsIndeterminate = false;

            PBar2.Orientation = Orientation.Horizontal;

            PBar2.Width = 200;

            PBar2.Height = 20;

            Duration duration = new Duration(TimeSpan.FromSeconds(20));

            DoubleAnimation doubleanimation = new DoubleAnimation(200.0, duration);

            PBar2.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);

            SBar.Items.Add(PBar2);

            PBar2.ValueChanged += new RoutedPropertyChangedEventHandler<double>(PBar2_ValueChanged);
            
        }

        void PBar2_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            if (e.NewValue == 100.0)
                MessageBox.Show("It is 100%");
        }

        private void btnGo_Click(object sender, RoutedEventArgs e)
        {

            test();
            


            /*
            String[,] Questions = new String[3, 5];
            int row = 0, col = 0;

            try
            {
                using (StreamReader reader = new StreamReader("QuestionsFile.txt"))
                {
                    String line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (col == 5)
                        {
                            row++;
                            col = 0;
                        }
                        Questions[row, col] = line;
                        col++;
                    }
                }

                txtOutput.Text = Questions[0, 4] + "\n" + Questions[1, 4] + "\n" + Questions[2, 4];


                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        txtOutput.Text += Questions[i, j];
                        txtOutput.Text += "\n";
                    }
                }
                

            }
            catch (Exception err)
            {
                MessageBox.Show("error reading");
                txtOutput.Text = err.Message;
                txtOutput.Text += "\n";
                txtOutput.Text = err.StackTrace;

            }
            */
        }  


    }
}
